package com.habitracker.model;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

public class Habit {
    private String name;
    private LocalDate createDate;
    private int totalCheckInDays;
    private int maxContinuousDays;

    public Habit(String name) {
        this.name = name;
        this.createDate = LocalDate.now();
        this.totalCheckInDays = 0;
        this.maxContinuousDays = 0;
    }

    public String getName() { return name; }
    public LocalDate getCreateDate() { return createDate; }
    public String getFormattedCreateDate() {
        return createDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
    }
    public int getTotalCheckInDays() { return totalCheckInDays; }
    public int getMaxContinuousDays() { return maxContinuousDays; }

    public void checkIn() {
        totalCheckInDays++;
        maxContinuousDays = Math.max(maxContinuousDays, totalCheckInDays);
    }
}